package sheshen.come.cn.sheshen.feature;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import sheshen.come.cn.sheshen.R;
import sheshen.come.cn.sheshen.base.BaseFragment;

import sheshen.come.cn.sheshen.feature.adapter.FeatureListAdapter;
import sheshen.come.cn.sheshen.feature.adapter.GatherAdapter;
import sheshen.come.cn.sheshen.feature.ui.GatherActivity;
import sheshen.come.cn.sheshen.navigation.imp.DefaultNavigation;

/**
 * Created by MyPC on 2017/2/18.
 */

public class FeaturesFragment extends BaseFragment implements AdapterView.OnItemClickListener{

    @Override
    protected View getContentView(LayoutInflater inflater, ViewGroup container) {
        return inflater.inflate(R.layout.fragment_mine,container,false);
    }

    @Override
    protected void initViews(View contentView) {
        initNavigation(contentView);

    }
    private ListView lv;
    private FeatureListAdapter adapter;
    private void initNavigation(View viewContent){
        DefaultNavigation.Builder builder = new DefaultNavigation.Builder(getContext(),(ViewGroup) viewContent);
        builder.setCenterText("功能").create().createAndBind();
        lv = (ListView) viewContent.findViewById(R.id.lv);
        adapter = new FeatureListAdapter(getContext(),null);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(this);
    }

    @Override
    protected void initListeners() {

    }


    @Override
    protected void initDatas() {
        List<String> list = new ArrayList<>();
        String[] str = getResources().getStringArray(R.array.featrue);
       for (int i = 0;i<str.length;i++){
           list.add(str[i]);
       }
      adapter.append(list);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Intent intent = new Intent(getContext(), GatherActivity.class);
        startActivity(intent);
    }
}
